//
//  ByViewMyHeader.m
//  mijifen_ios
//
//  Created by mc on 2017/10/20.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewMyHeader.h"
#import "ByModelUser.h"
@implementation ByViewMyHeader
{
    UIImageView *_icon;
    UILabel     *_nameLabel;
}
- (instancetype)init{
    if (self = [super init]) {
        [self createViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)createViews{
    _icon = [[UIImageView alloc] init];
    [self addSubview:_icon];
    
    _nameLabel = [[UILabel alloc] init];
    [self addSubview:_nameLabel];
}

- (void)setUser:(ByModelUser *)user{
    _user = user;
    
    CGFloat x,y,width,height;
    x = (SCREEN_WIDTH - 100) / 2;
    y = 15;
    width = height = 100;
    _icon.frame = CGRectMake(x, y, width, height);
    _icon.layer.cornerRadius = 100 / 2;
    _icon.layer.masksToBounds = YES;
    
    x = 10;
    y = _icon.bottom + 15;
    width = SCREEN_WIDTH - x * 2;
    height = 20;
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.font = FONT(16);
    _nameLabel.frame = CGRectMake(x, y, width, height);
    
    // 我的测试数据
    _icon.backgroundColor = [UIColor redColor];
    _nameLabel.text = _user.name;
}

@end
